#include "Text.h"

//  default constructor-
Text::Text() {
    fColor.r = fColor.g = fColor.b = 245;
}

TTF_Font* Text::OnLoad(char* file, int ptSize){
     font = TTF_OpenFont(file, ptSize);
     if (!font){
        printf("TTF_OpenFont: %s\n", TTF_GetError());
        exit(666);
    }
     return font;
}

void Text::OnRender(SDL_Surface* Surf_Display, TTF_Font* Surf_Font, int x, int y, char* message){
    imgTxt = TTF_RenderText_Solid(Surf_Font, message, fColor);
    Surface::OnDraw(Surf_Display, imgTxt, x, y);
    SDL_FreeSurface(imgTxt);
}

void Text::OnRender(SDL_Surface* Surf_Display, TTF_Font* Surf_Font, int x, int y, char* message, SDL_Color txtColor){
    imgTxt = TTF_RenderText_Solid(Surf_Font, message, txtColor);
    Surface::OnDraw(Surf_Display, imgTxt, x, y);
    SDL_FreeSurface(imgTxt);
}

void Text::OnRender(SDL_Surface* Surf_Display, TTF_Font* Surf_Font, int x, int y, char* message, SDL_Color txtColor, SDL_Color backColor){
    imgTxt = TTF_RenderText_Shaded(Surf_Font, message, txtColor, backColor);
    Surface::OnDraw(Surf_Display, imgTxt, x, y);
    SDL_FreeSurface(imgTxt  );
}
